package com.tsingteng.cosfun.ui.cosfun.presenter;

import com.tsingteng.cosfun.bean.BaseDataBean;
import com.tsingteng.cosfun.callback.RxObserver;
import com.tsingteng.cosfun.mvp.presenter.BasePresenter;
import com.tsingteng.cosfun.ui.cosfun.contract.ZanContract;
import com.tsingteng.cosfun.ui.cosfun.imodel.ZanModel;

public class ZanPresenter extends BasePresenter<ZanContract.IZanView> implements ZanContract.IZanPresenter {
    ZanModel zanModel = null;
    ZanContract.IZanView iZanView = null;

    public ZanPresenter() {
        this.zanModel = new ZanModel();
    }

    //视频点赞
    @Override
    public void getOpusZan(String workId, String c, String deviceId, String type) {
        iZanView = getView();
        RxObserver<BaseDataBean<String>> rxObserver = new RxObserver<BaseDataBean<String>>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {
                iZanView.showFail(errorMsg);
            }

            @Override
            protected void onSuccess(BaseDataBean<String> stringBaseDataBean) {
                iZanView.showLogonResult();
            }
        };
        zanModel.getOpusZan(workId, c, deviceId, type, rxObserver);
        addDisposable(rxObserver);
    }


    //不感兴趣
    @Override
    public void getLoseInterest(String workId, String c, String deviceId, String userId, String type) {
        iZanView = getView();
        RxObserver<BaseDataBean<String>> rxObserver = new RxObserver<BaseDataBean<String>>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {
                iZanView.showFail(errorMsg);
            }

            @Override
            protected void onSuccess(BaseDataBean<String> stringBaseDataBean) {
                iZanView.showLogonResult();
            }
        };
        zanModel.getLoseInterest(workId, c, deviceId, userId, type, rxObserver);
        addDisposable(rxObserver);
    }
}
